<template>
  <div class="header">
    <div class="header-left">
      <img src="@/assets/photo/logo.png" />
      <i
        class="iconfont"
        @click="TOGGLE_SIDEBAR"
        :class="!sidebar ? 'icon-foldLeft' : 'icon-foldRight'"
      ></i>
    </div>
    <div class="header-right">
      <span>{{ username }}({{ type == 1 ? "超级管理员" : "普通管理员" }})</span>
      <span><img src="@/assets/photo/gita.gif" /></span>
      <span>|</span>
      <span class="quit"><a href="#" @click="LogoutAction">退出登录</a></span>
      <span><img class="cn" src="@/assets/photo/cn.png" /></span>
    </div>
  </div>
</template>

<script>
// 引入动作的辅助函数
import { mapMutations, mapActions, mapGetters } from "vuex";

export default {
  name: "myheader",
  methods: {
    ...mapMutations(["TOGGLE_SIDEBAR"]),
    ...mapActions(["LogoutAction"]),
  },
  computed: {
    ...mapGetters(["sidebar", "username", "type"]),
  },
};
</script>

<style lang="scss" scoped>
.header {
  height: 50px;
  background-color: #fff;
  line-height: 50px;
  display: flex;
  justify-content: space-between;
}

.header-left {
  width: 100px;
  height: 50px;
  display: flex;
  align-items: center;
  margin-left: 15px;
}

i {
  padding-left: 30px;
}

.header-left img {
  width: 100%;
}

.header-right {
  height: 50px;
  width: 350px;
  display: flex;
  align-items: center;
  justify-content: right;
}

.header-right span {
  margin-left: 5px;
  font-size: 12px;
  color: #504e4e;
  vertical-align: middle;
}

.header-right img {
  height: 25px;
  width: 25px;
  vertical-align: middle;
}

.header-right .cn {
  height: 50px;
  width: 50px;
}

.quit a {
  color: #60acff;
}
</style>
